{% extends "baseTemp/base_detail_list.html" %}
{% load staticfiles %}

{% block title %}
	<title>天天生鲜-商品列表</title>
	<meta name="description" content="">
	<meta name="keywords" content="">
{% endblock title %}


{% block main_content %}
	<div class="breadcrumb">
		<a href="#">全部分类</a>
		<span>></span>
		<a href="#">{{ ctype.name }}</a>
	</div>

	<div class="main_wrap clearfix">
		<div class="l_wrap fl clearfix">
			<div class="new_goods">
				<h3>新品推荐</h3>
				<ul>
					{% for new_sku in new_skus %}
						<li>
							<a href="{% url 'commod:detail' new_sku.id %}">
								<img src="{{ new_sku.image.url }}">
							</a>
							<h4>
								<a href="{% url 'commod:detail' new_sku.id %}">{{ new_sku.name }}</a>
							</h4>
							<div class="prize">￥{{ new_sku.price }}</div>
						</li>
					{% endfor %}
				</ul>
			</div>
		</div>

		<div class="r_wrap fr clearfix">
			<div class="sort_bar">
				<a href="{% url 'commod:detail_list' ctype.id 1 %}"  {% if sort == 'default' %} class="active" {% endif %}>默认</a>
				<a href="{% url 'commod:detail_list' ctype.id 1 %}?sort=price" {% if sort == 'price' %} class="active" {% endif %}>价格</a>
				<a href="{% url 'commod:detail_list' ctype.id 1 %}?sort=sales" {% if sort == 'sales' %} class="active" {% endif %}>人气</a>
			</div>

			<ul class="goods_type_list clearfix">
				{% for sku in pages.object_list %}
					<li>
						<a href="{% url 'commod:detail' sku.id %}"><img src="{{ sku.image.url }}"></a>
						<h4><a href="{% url 'commod:detail' sku.id %}">{{ sku.name }}</a></h4>
						<div class="operate">
							<span class="prize">￥{{ sku.price }}</span>
							<span class="unit">{{ sku.price }}/{{ sku.unite }}</span>
							<a href="#" class="add_goods" title="加入购物车"></a>
						</div>
					</li>
				{% endfor %}
			</ul>

			<div class="pagenation">
				{# 判断是否存在上一页 #}
				{% if pages.has_previous %}
				   <a href="{% url 'commod:detail_list' ctype.id pages.previous_page_number %}?sort={{ sort }}"><上一页</a>
				 {% else %}
				   <span><a><上一页</a></span>
				 {% endif %}

				{# 页码显示 #}
				{% for page_index in page_list %}
					{% if page_index == pages.number %}
						<a class="active">{{ page_index }}</a>
					{% else %}
						<a href="{% url 'commod:detail_list' ctype.id page_index %}?sort={{ sort }}">{{ page_index }}</a>
					{% endif %}
				{% endfor %}

				{# 判断是否存在下一页 #}
				{% if pages.has_next %}
				  <span><a href="{% url 'commod:detail_list' ctype.id pages.next_page_number %}?sort={{ sort }}">下一页</a></span>
				{% else %}
				  <span><a>下一页</a></span>
				{% endif %}
			</div>
		</div>
	</div>
{% endblock main_content %}
